package core;

import java.awt.Point;
import java.util.ArrayList;
import java.util.LinkedList;

public class VendorList {
    
    private static ArrayList<Vendor> vendors = new ArrayList<Vendor>();       
    
    public static ArrayList<Vendor> getList() {
        return vendors;
    }  
    
    public static Vendor getVendor(int i) {
        return vendors.get(i);
    }
    
    public static void addVendor(Vendor vendor) {
        boolean found = false;
        for(int i=0;i<vendors.size();i++) {
            if(vendors.get(i).NAME.equals(vendor.NAME)) {
                found = true;
                break;
            }
        }
        if(!found)
            vendors.add(vendor);
    }
    
    public static int count() {
        return vendors.size();
    }
    
    public static Point getPosVendor(String _name){
        Point _pos = new Point(0,0);
        for(int it=0; it<vendors.size(); it++){
            //System.out.println("getPos("+_name+") "+vendors.get(it).NAME+" = "+vendors.get(it).getPoint().x+","+vendors.get(it).getPoint().y);
            if (vendors.get(it).NAME.equals(_name)){
                _pos = vendors.get(it).getPoint();
            }
        }
        return _pos;
    }
    
    public static String getListNameVendor(int machine){
        String listNameVendor = "";
        for(int i=0;i<vendors.size();i++){
            for(int j=0; j<vendors.get(i).getAllMachinesForRent().size(); j++){
                if (vendors.get(i).getAllMachinesForRent().get(j).TYPE==machine){
                    listNameVendor = listNameVendor + vendors.get(i).NAME;
                }
            }
        }
        return listNameVendor;
    }
}
